#include <bits/stdc++.h>
using namespace std;

const int R = 500;
const char block[6][8] = {
	"..+---+",
	"./   /|",
	"+---+ |",
	"|   | +",
	"|   |/.",
	"+---+.."};
char mp[R][R];
int a[50][50];
void fillBlock(int x, int y)
{
	int i, j;
	for (i = x; i < x + 6; ++i)
	{
		for (j = y; j < y + 7; ++j)
		{
			if (mp[i][j] != '.' && block[i - x][j - y] == '.') // 被填充过就取消背景
			{
				continue;
			}
			mp[i][j] = block[i - x][j - y];
		}
	}
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, m, i, j, k, beginX, beginY, h, w;
	cin >> n >> m;
	w = (m - 1) * 4 + 7 + (n - 1) * 2;
	h = 6 + (n - 1) * 2;
	for (i = 1; i <= n; ++i)
	{
		for (j = 1; j <= m; ++j)
		{
			cin >> a[i][j];
			h = max(h, (a[i][j] - 1) * 3 + 6 + (n - i) * 2); // 伸出去的+在这一层的+下面的
		}
	}
	// 初始化
	memset(mp, '.', sizeof(mp));
	// 填充
	for (i = 1; i <= n; ++i)
	{
		for (j = 1; j <= m; ++j)
		{
			beginY = 2 * (n - i) + 1 + (j - 1) * 4;
			for (k = 1; k <= a[i][j]; ++k)
			{
				beginX = h - 5 - (n - i) * 2 - (k - 1) * 3;
				fillBlock(beginX, beginY);
			}
		}
	}
	// 输出
	for (i = 1; i <= h; ++i)
	{
		for (j = 1; j <= w; ++j)
		{
			cout << mp[i][j];
		}
		cout << '\n';
	}
	return 0;
}
